#include "WorldProcess.h"
#include "ScriptMgr.h"
#include "NGLog.h"
#include "GatewayOpcodes.h"
#include "GameUserCommand.h"
#include "MJScriptWorldProcess.h"
#include "OpcodesEx.h"
#include "GameServerCommand.h"
#include "CenterBattleManager.h"
#include "CenterBattleLogManager.h"
#include "url.h"
#include "json/json.h"
#include "nxweb/nxweb.h"
#include "MD5.h"

#include "CenterMatchLogic.h"
#include "CenterMatchChannelManager.h"
#include "CenterMatchScriptWorldProcess.h"
#include "GameDefine.h"
#include LOGIC_MGR_PATH

#include "GameDataEnum.h"


#define SECUREKEY "mef3mervzl1SykohhufmdkhvdbCpokkt"
// 比赛协议注册
void  register_CM_world_process(ScriptMgr * mgr)
{
	//CMSS_CenterMatch_PublicMatchList = 0x2700,				//比赛列表
	mgr->register_server_process(CMSS_CenterMatch_PublicMatchList, script_world_process_CM_MatchList);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_PublicMatchList, "script_world_process_CM_MatchList");

	// CMSS_CenterMatch_MatchInfo = 0x2702,				//比赛信息
	mgr->register_server_process(CMSS_CenterMatch_MatchInfo, script_world_process_CM_MatchInfo);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_MatchInfo, "script_world_process_CM_MatchInfo");

	//CMSS_CenterMatch_EnrollmentForm = 0x2703,			//报名列表
	mgr->register_server_process(CMSS_CenterMatch_EnrollmentForm, script_world_process_CM_EnrollmentForm);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_EnrollmentForm, "script_world_process_CM_EnrollmentForm");

	//CMSS_CenterMatch_SignUp = 0x2704,					//报名
	mgr->register_server_process(CMSS_CenterMatch_SignUp, script_world_process_CM_SignUp);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_SignUp, "script_world_process_CM_SignUp");

	//CMSS_CenterMatch_ReviewSignUp = 0x2705,					//审核报名
	mgr->register_server_process(CMSS_CenterMatch_ReviewSignUp, script_world_process_CM_ReviewSignUp);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_ReviewSignUp, "script_world_process_CM_ReviewSignUp");

	//CMSS_CenterMatch_PlayerInfoListInCenter = 0x2706,					//玩家信息
	mgr->register_server_process(CMSS_CenterMatch_PlayerInfoListInCenter, script_world_process_CM_PlayerInfoList);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_PlayerInfoListInCenter, "script_world_process_CM_PlayerInfoList");

	//CMSS_CenterMatch_CreateMatch = 0x2707,						//创建比赛
	mgr->register_server_process(CMSS_CenterMatch_CreateMatch, script_world_process_CM_CreateMatch);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_CreateMatch, "script_world_process_CM_CreateMatch");

	//CMSS_CenterMatch_EnterMatch = 0x2708,						//加入比赛
	mgr->register_server_process(CMSS_CenterMatch_EnterMatch, script_world_process_CM_EnterGameMatch);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_EnterMatch, "script_world_process_CM_EnterGameMatch");


	//CMSS_CenterMatch_PlayerEnterMatchList = 0x2709,						//已经入比赛列表
	mgr->register_server_process(CMSS_CenterMatch_PlayerEnterMatchList, script_world_process_CM_GiveEnterGameMatch);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_PlayerEnterMatchList, "script_world_process_CM_GiveEnterGameMatch");

	//CMSS_CenterMatch_PlayerGiveUpMatch = 0x270A,						//玩家退赛
	mgr->register_server_process(CMSS_CenterMatch_PlayerGiveUpMatch, script_world_process_CM_PlayerGiveUP);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_PlayerGiveUpMatch, "script_world_process_CM_PlayerGiveUP");

	//CMSS_CenterMatch_CenterMatchDissolve = 0x270B,
	mgr->register_server_process(CMSS_CenterMatch_CenterMatchDissolve, script_world_process_CM_DissolveMatch);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_CenterMatchDissolve, "script_world_process_CM_DissolveMatch");
	
	// CMSS_CenterMatch_CenterMatchWatch = 0x270C,						//比赛观战
	mgr->register_server_process(CMSS_CenterMatch_CenterMatchWatch, script_world_process_CM_WatchMatch);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_CenterMatchWatch, "script_world_process_CM_WatchMatch");
	
	//CMSS_CenterMatch_CenterMatchLog = 0x270D,							//比赛游戏记录
	mgr->register_server_process(CMSS_CenterMatch_CenterMatchLog, script_world_process_CM_CenterMatchLog);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_CenterMatchLog, "script_world_process_CM_CenterMatchLog");


	//CMSS_CenterMatch_CenterMatchLoopLog = 0x270E,							//比赛游戏记录
	mgr->register_server_process(CMSS_CenterMatch_CenterMatchLoopLog, script_world_process_CM_CenterMatchLoopLog);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_CenterMatchLoopLog, "script_world_process_CM_CenterMatchLoopLog");


	//CMSS_CenterMatch_CenterMatchBattlelog = 0x270F,							//单局比赛游戏记录
	mgr->register_server_process(CMSS_CenterMatch_CenterMatchBattlelog, script_world_process_CM_CenterMatchBattlelog);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_CenterMatchBattlelog, "script_world_process_CM_CenterMatchBattlelog");

	//CMSS_CenterMatch_JoinChannel = 0x2724,						//进入牌桌
	mgr->register_server_process(CMSS_CenterMatch_JoinChannel, script_world_process_CM_JoinChannel);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSS_CenterMatch_JoinChannel, "script_world_process_CM_JoinChannel");
	
	// CMSG_REQUIE_MATCHZONELIST = 0x2740,	// 请求赛区列表
	mgr->register_server_process(CMSG_REQUIE_MATCHZONELIST, script_world_process_requirematchzonelist);
	Log.Debug("World Process", "Register opcode 0x%02x Process:[%s]", CMSG_REQUIE_MATCHZONELIST, "script_world_process_requirematchzonelist");
	
	//GameCommand_CreateCenterMatch = 2000, 	// 后台创建比赛
	mgr->register_gateway_command(GameCommand_CreateCenterMatch, script_process_world_game_command_CreateCenterMatch);

	//GameCommand_SetCenterMatch = 2001, 	// 后台修改比赛
	mgr->register_gateway_command(GameCommand_SetCenterMatch, script_process_world_game_command_SetCenterMatch);

	//GameCommand_KillCenterMatch = 2002, 	// 后台关闭比赛
	mgr->register_gateway_command(GameCommand_KillCenterMatch, script_process_world_game_command_KillCenterMatch);
	
}

//-----------------------------------------------------------------------


